home *** CD-ROM | disk | FTP | other *** search
/ Mac Format 1995 June / MacFormat 25.iso / Shareware City / Developers / OutOfPhase1.1 Source / OutOfPhase Folder / PcodeDisassembly.c < prev    next >
Text File  |  1994-12-28  |  29KB  |  753 lines

  1. /* PcodeDisassembly.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. #include "MiscInfo.h"
  26. #include "Audit.h"
  27. #include "Debug.h"
  28. #include "Definitions.h"
  29.  
  30. #define SHOW_ME_OPCODEREC  /* we need to be able to see contents of OpcodeRec */
  31. #include "PcodeDisassembly.h"
  32. #include "Memory.h"
  33. #include "PcodeObject.h"
  34. #include "Numbers.h"
  35.  
  36.  
  37. /* this defines the maximum length of one line of disassembly.  it should */
  38. /* be more than enough. */
  39. #define DISBUFSIZE (1024)
  40.  
  41.  
  42. /* utility routine for incrementally constructing each disassmbly line */
  43. static void                CopyStrOver(char Buffer[DISBUFSIZE], char* String, long* Index)
  44.     {
  45.         while ((*String != 0) && (*Index < DISBUFSIZE))
  46.             {
  47.                 Buffer[*Index] = *String;
  48.                 String += 1;
  49.                 (*Index) += 1;
  50.             }
  51.     }
  52.  
  53.  
  54. /* disassemble pcode and return a string block containing all the data */
  55. char*                            DisassemblePcode(PcodeRec* Pcode, char CarriageReturn)
  56.     {
  57.         char*                        Thang;
  58.         char                        Buffer[DISBUFSIZE];
  59.         long                        Scan;
  60.         long                        Limit;
  61.         long                        BuffIndex;
  62.         OpcodeRec*            OpcodeArray;
  63.  
  64.         CheckPtrExistence(Pcode);
  65.         Thang = AllocPtrCanFail(0,"DisassemblePcodeThang");
  66.         if (Thang == NIL)
  67.             {
  68.                 return NIL;
  69.             }
  70.         OpcodeArray = GetOpcodeFromPcode(Pcode);
  71.         Limit = PtrSize((char*)OpcodeArray) / sizeof(OpcodeRec);
  72.         Scan = 0;
  73.         while (Scan < Limit)
  74.             {
  75.                 char*                            StringTemp;
  76.  
  77.                 BuffIndex = 0;
  78.                 StringTemp = IntegerToString(Scan);
  79.                 if (StringTemp == NIL)
  80.                     {
  81.                      FailurePoint:
  82.                         ReleasePtr(Thang);
  83.                         return NIL;
  84.                     }
  85.                 BuffIndex = PtrSize(StringTemp);
  86.                 ERROR(BuffIndex > DISBUFSIZE,PRERR(ForceAbort,"DisassemblePcode:  buffer overrun"));
  87.                 CopyData(StringTemp,Buffer,BuffIndex);
  88.                 while (BuffIndex < 8)
  89.                     {
  90.                         Buffer[BuffIndex] = 32;
  91.                         BuffIndex += 1;
  92.                     }
  93.                 ReleasePtr(StringTemp);
  94.                 switch (OpcodeArray[Scan].Opcode)
  95.                     {
  96.                         case epFuncCallUnresolved: /* <opcode> ^"<functionname>" ^[paramlist] <returntype> <reserved> */
  97.                             CopyStrOver(Buffer,"call_unlinked ",&BuffIndex);
  98.                             CopyStrOver(Buffer,OpcodeArray[Scan + 1].ImmediateString,&BuffIndex);
  99.                             Scan += 5;
  100.                             break;
  101.                         case epFuncCallResolved: /* <opcode> ^"<functionname>" ^[paramlist] <returntype> ^<OpcodeRec> */
  102.                             CopyStrOver(Buffer,"call_linked ",&BuffIndex);
  103.                             CopyStrOver(Buffer,OpcodeArray[Scan + 1].ImmediateString,&BuffIndex);
  104.                             Scan += 5;
  105.                             break;
  106.  
  107.                         case epErrorTrap: /* <opcode> ^"<errorstring>" */
  108.                             CopyStrOver(Buffer,"error ",&BuffIndex);
  109.                          AppendStringPoint:
  110.                             CopyStrOver(Buffer,"\x22",&BuffIndex);
  111.                             CopyStrOver(Buffer,OpcodeArray[Scan + 1].ImmediateString,&BuffIndex);
  112.                             CopyStrOver(Buffer,"\x22",&BuffIndex);
  113.                          ScanPlusTwoPoint:
  114.                             Scan += 2;
  115.                             break;
  116.  
  117.                         case epOperationBooleanEqual: /* <opcode> */
  118.                             CopyStrOver(Buffer,"eq.b",&BuffIndex);
  119.                          ScanPlusOnePoint:
  120.                             Scan += 1;
  121.                             break;
  122.                         case epOperationBooleanNotEqual:
  123.                             CopyStrOver(Buffer,"neq.b",&BuffIndex);
  124.                             goto ScanPlusOnePoint;
  125.                         case epOperationBooleanAnd:
  126.                             CopyStrOver(Buffer,"and.b",&BuffIndex);
  127.                             goto ScanPlusOnePoint;
  128.                         case epOperationBooleanOr:
  129.                             CopyStrOver(Buffer,"or.b",&BuffIndex);
  130.                             goto ScanPlusOnePoint;
  131.                         case epOperationBooleanNot:
  132.                             CopyStrOver(Buffer,"not.b",&BuffIndex);
  133.                             goto ScanPlusOnePoint;
  134.                         case epOperationBooleanToInteger:
  135.                             CopyStrOver(Buffer,"booltoint",&BuffIndex);
  136.                             goto ScanPlusOnePoint;
  137.                         case epOperationBooleanToFloat:
  138.                             CopyStrOver(Buffer,"booltofloat",&BuffIndex);
  139.                             goto ScanPlusOnePoint;
  140.                         case epOperationBooleanToDouble:
  141.                             CopyStrOver(Buffer,"booltodouble",&BuffIndex);
  142.                             goto ScanPlusOnePoint;
  143.                         case epOperationBooleanToFixed:
  144.                             CopyStrOver(Buffer,"booltofixed",&BuffIndex);
  145.                             goto ScanPlusOnePoint;
  146.                         case epOperationIntegerAdd:
  147.                             CopyStrOver(Buffer,"add.i",&BuffIndex);
  148.                             goto ScanPlusOnePoint;
  149.                         case epOperationIntegerSubtract:
  150.                             CopyStrOver(Buffer,"sub.i",&BuffIndex);
  151.                             goto ScanPlusOnePoint;
  152.                         case epOperationIntegerNegation:
  153.                             CopyStrOver(Buffer,"neg.i",&BuffIndex);
  154.                             goto ScanPlusOnePoint;
  155.                         case epOperationIntegerMultiply:
  156.                             CopyStrOver(Buffer,"mult.i",&BuffIndex);
  157.                             goto ScanPlusOnePoint;
  158.                         case epOperationIntegerDivide:
  159.                             CopyStrOver(Buffer,"div.i",&BuffIndex);
  160.                             goto ScanPlusOnePoint;
  161.                         case epOperationIntegerModulo:
  162.                             CopyStrOver(Buffer,"mod.i",&BuffIndex);
  163.                             goto ScanPlusOnePoint;
  164.                         case epOperationIntegerShiftLeft:
  165.                             CopyStrOver(Buffer,"asl.i",&BuffIndex);
  166.                             goto ScanPlusOnePoint;
  167.                         case epOperationIntegerShiftRight:
  168.                             CopyStrOver(Buffer,"asr.i",&BuffIndex);
  169.                             goto ScanPlusOnePoint;
  170.                         case epOperationIntegerGreaterThan:
  171.                             CopyStrOver(Buffer,"gr.i",&BuffIndex);
  172.                             goto ScanPlusOnePoint;
  173.                         case epOperationIntegerLessThan:
  174.                             CopyStrOver(Buffer,"ls.i",&BuffIndex);
  175.                             goto ScanPlusOnePoint;
  176.                         case epOperationIntegerGreaterThanOrEqual:
  177.                             CopyStrOver(Buffer,"greq.i",&BuffIndex);
  178.                             goto ScanPlusOnePoint;
  179.                         case epOperationIntegerLessThanOrEqual:
  180.                             CopyStrOver(Buffer,"lseq.i",&BuffIndex);
  181.                             goto ScanPlusOnePoint;
  182.                         case epOperationIntegerEqual:
  183.                             CopyStrOver(Buffer,"eq.i",&BuffIndex);
  184.                             goto ScanPlusOnePoint;
  185.                         case epOperationIntegerNotEqual:
  186.                             CopyStrOver(Buffer,"neq.i",&BuffIndex);
  187.                             goto ScanPlusOnePoint;
  188.                         case epOperationIntegerAbs:
  189.                             CopyStrOver(Buffer,"abs.i",&BuffIndex);
  190.                             goto ScanPlusOnePoint;
  191.                         case epOperationIntegerToBoolean:
  192.                             CopyStrOver(Buffer,"inttobool",&BuffIndex);
  193.                             goto ScanPlusOnePoint;
  194.                         case epOperationIntegerToFloat:
  195.                             CopyStrOver(Buffer,"inttofloat",&BuffIndex);
  196.                             goto ScanPlusOnePoint;
  197.                         case epOperationIntegerToDouble:
  198.                             CopyStrOver(Buffer,"inttodouble",&BuffIndex);
  199.                             goto ScanPlusOnePoint;
  200.                         case epOperationIntegerToFixed:
  201.                             CopyStrOver(Buffer,"inttofixed",&BuffIndex);
  202.                             goto ScanPlusOnePoint;
  203.                         case epOperationFloatAdd:
  204.                             CopyStrOver(Buffer,"add.s",&BuffIndex);
  205.                             goto ScanPlusOnePoint;
  206.                         case epOperationFloatSubtract:
  207.                             CopyStrOver(Buffer,"sub.s",&BuffIndex);
  208.                             goto ScanPlusOnePoint;
  209.                         case epOperationFloatNegation:
  210.                             CopyStrOver(Buffer,"neg.s",&BuffIndex);
  211.                             goto ScanPlusOnePoint;
  212.                         case epOperationFloatMultiply:
  213.                             CopyStrOver(Buffer,"mult.s",&BuffIndex);
  214.                             goto ScanPlusOnePoint;
  215.                         case epOperationFloatDivide:
  216.                             CopyStrOver(Buffer,"div.s",&BuffIndex);
  217.                             goto ScanPlusOnePoint;
  218.                         case epOperationFloatGreaterThan:
  219.                             CopyStrOver(Buffer,"gr.s",&BuffIndex);
  220.                             goto ScanPlusOnePoint;
  221.                         case epOperationFloatLessThan:
  222.                             CopyStrOver(Buffer,"ls.s",&BuffIndex);
  223.                             goto ScanPlusOnePoint;
  224.                         case epOperationFloatGreaterThanOrEqual:
  225.                             CopyStrOver(Buffer,"greq.s",&BuffIndex);
  226.                             goto ScanPlusOnePoint;
  227.                         case epOperationFloatLessThanOrEqual:
  228.                             CopyStrOver(Buffer,"lseq.s",&BuffIndex);
  229.                             goto ScanPlusOnePoint;
  230.                         case epOperationFloatEqual:
  231.                             CopyStrOver(Buffer,"eq.s",&BuffIndex);
  232.                             goto ScanPlusOnePoint;
  233.                         case epOperationFloatNotEqual:
  234.                             CopyStrOver(Buffer,"neq.s",&BuffIndex);
  235.                             goto ScanPlusOnePoint;
  236.                         case epOperationFloatAbs:
  237.                             CopyStrOver(Buffer,"abs.s",&BuffIndex);
  238.                             goto ScanPlusOnePoint;
  239.                         case epOperationFloatToBoolean:
  240.                             CopyStrOver(Buffer,"floattobool",&BuffIndex);
  241.                             goto ScanPlusOnePoint;
  242.                         case epOperationFloatToInteger:
  243.                             CopyStrOver(Buffer,"floattoint",&BuffIndex);
  244.                             goto ScanPlusOnePoint;
  245.                         case epOperationFloatToDouble:
  246.                             CopyStrOver(Buffer,"floattodouble",&BuffIndex);
  247.                             goto ScanPlusOnePoint;
  248.                         case epOperationFloatToFixed:
  249.                             CopyStrOver(Buffer,"floattofixed",&BuffIndex);
  250.                             goto ScanPlusOnePoint;
  251.                         case epOperationDoubleAdd:
  252.                             CopyStrOver(Buffer,"add.d",&BuffIndex);
  253.                             goto ScanPlusOnePoint;
  254.                         case epOperationDoubleSubtract:
  255.                             CopyStrOver(Buffer,"sub.d",&BuffIndex);
  256.                             goto ScanPlusOnePoint;
  257.                         case epOperationDoubleNegation:
  258.                             CopyStrOver(Buffer,"neg.d",&BuffIndex);
  259.                             goto ScanPlusOnePoint;
  260.                         case epOperationDoubleMultiply:
  261.                             CopyStrOver(Buffer,"mult.d",&BuffIndex);
  262.                             goto ScanPlusOnePoint;
  263.                         case epOperationDoubleDivide:
  264.                             CopyStrOver(Buffer,"div.d",&BuffIndex);
  265.                             goto ScanPlusOnePoint;
  266.                         case epOperationDoubleGreaterThan:
  267.                             CopyStrOver(Buffer,"gr.d",&BuffIndex);
  268.                             goto ScanPlusOnePoint;
  269.                         case epOperationDoubleLessThan:
  270.                             CopyStrOver(Buffer,"ls.d",&BuffIndex);
  271.                             goto ScanPlusOnePoint;
  272.                         case epOperationDoubleGreaterThanOrEqual:
  273.                             CopyStrOver(Buffer,"greq.d",&BuffIndex);
  274.                             goto ScanPlusOnePoint;
  275.                         case epOperationDoubleLessThanOrEqual:
  276.                             CopyStrOver(Buffer,"lseq.d",&BuffIndex);
  277.                             goto ScanPlusOnePoint;
  278.                         case epOperationDoubleEqual:
  279.                             CopyStrOver(Buffer,"eq.d",&BuffIndex);
  280.                             goto ScanPlusOnePoint;
  281.                         case epOperationDoubleNotEqual:
  282.                             CopyStrOver(Buffer,"neq.d",&BuffIndex);
  283.                             goto ScanPlusOnePoint;
  284.                         case epOperationDoubleAbs:
  285.                             CopyStrOver(Buffer,"abs.d",&BuffIndex);
  286.                             goto ScanPlusOnePoint;
  287.                         case epOperationDoubleToBoolean:
  288.                             CopyStrOver(Buffer,"doubletobool",&BuffIndex);
  289.                             goto ScanPlusOnePoint;
  290.                         case epOperationDoubleToInteger:
  291.                             CopyStrOver(Buffer,"doubletoint",&BuffIndex);
  292.                             goto ScanPlusOnePoint;
  293.                         case epOperationDoubleToFloat:
  294.                             CopyStrOver(Buffer,"doubletofloat",&BuffIndex);
  295.                             goto ScanPlusOnePoint;
  296.                         case epOperationDoubleToFixed:
  297.                             CopyStrOver(Buffer,"doubletofixed",&BuffIndex);
  298.                             goto ScanPlusOnePoint;
  299.                         case epOperationDoubleSin:
  300.                             CopyStrOver(Buffer,"sin.d",&BuffIndex);
  301.                             goto ScanPlusOnePoint;
  302.                         case epOperationDoubleCos:
  303.                             CopyStrOver(Buffer,"cos.d",&BuffIndex);
  304.                             goto ScanPlusOnePoint;
  305.                         case epOperationDoubleTan:
  306.                             CopyStrOver(Buffer,"tan.d",&BuffIndex);
  307.                             goto ScanPlusOnePoint;
  308.                         case epOperationDoubleAtan:
  309.                             CopyStrOver(Buffer,"atan.d",&BuffIndex);
  310.                             goto ScanPlusOnePoint;
  311.                         case epOperationDoubleLn:
  312.                             CopyStrOver(Buffer,"ln.d",&BuffIndex);
  313.                             goto ScanPlusOnePoint;
  314.                         case epOperationDoubleExp:
  315.                             CopyStrOver(Buffer,"exp.d",&BuffIndex);
  316.                             goto ScanPlusOnePoint;
  317.                         case epOperationDoubleSqrt:
  318.                             CopyStrOver(Buffer,"sqrt.d",&BuffIndex);
  319.                             goto ScanPlusOnePoint;
  320.                         case epOperationDoublePower:
  321.                             CopyStrOver(Buffer,"pow.d",&BuffIndex);
  322.                             goto ScanPlusOnePoint;
  323.                         case epOperationFixedAdd:
  324.                             CopyStrOver(Buffer,"add.f",&BuffIndex);
  325.                             goto ScanPlusOnePoint;
  326.                         case epOperationFixedSubtract:
  327.                             CopyStrOver(Buffer,"sub.f",&BuffIndex);
  328.                             goto ScanPlusOnePoint;
  329.                         case epOperationFixedNegation:
  330.                             CopyStrOver(Buffer,"neg.f",&BuffIndex);
  331.                             goto ScanPlusOnePoint;
  332.                         case epOperationFixedMultiply:
  333.                             CopyStrOver(Buffer,"mult.f",&BuffIndex);
  334.                             goto ScanPlusOnePoint;
  335.                         case epOperationFixedDivide:
  336.                             CopyStrOver(Buffer,"div.f",&BuffIndex);
  337.                             goto ScanPlusOnePoint;
  338.                         case epOperationFixedShiftLeft:
  339.                             CopyStrOver(Buffer,"asl.f",&BuffIndex);
  340.                             goto ScanPlusOnePoint;
  341.                         case epOperationFixedShiftRight:
  342.                             CopyStrOver(Buffer,"asr.f",&BuffIndex);
  343.                             goto ScanPlusOnePoint;
  344.                         case epOperationFixedGreaterThan:
  345.                             CopyStrOver(Buffer,"gr.f",&BuffIndex);
  346.                             goto ScanPlusOnePoint;
  347.                         case epOperationFixedLessThan:
  348.                             CopyStrOver(Buffer,"ls.f",&BuffIndex);
  349.                             goto ScanPlusOnePoint;
  350.                         case epOperationFixedGreaterThanOrEqual:
  351.                             CopyStrOver(Buffer,"greq.f",&BuffIndex);
  352.                             goto ScanPlusOnePoint;
  353.                         case epOperationFixedLessThanOrEqual:
  354.                             CopyStrOver(Buffer,"lseq.f",&BuffIndex);
  355.                             goto ScanPlusOnePoint;
  356.                         case epOperationFixedEqual:
  357.                             CopyStrOver(Buffer,"eq.f",&BuffIndex);
  358.                             goto ScanPlusOnePoint;
  359.                         case epOperationFixedNotEqual:
  360.                             CopyStrOver(Buffer,"neq.f",&BuffIndex);
  361.                             goto ScanPlusOnePoint;
  362.                         case epOperationFixedAbs:
  363.                             CopyStrOver(Buffer,"abs.f",&BuffIndex);
  364.                             goto ScanPlusOnePoint;
  365.                         case epOperationFixedToBoolean:
  366.                             CopyStrOver(Buffer,"fixedtobool",&BuffIndex);
  367.                             goto ScanPlusOnePoint;
  368.                         case epOperationFixedToInteger:
  369.                             CopyStrOver(Buffer,"fixedtoint",&BuffIndex);
  370.                             goto ScanPlusOnePoint;
  371.                         case epOperationFixedToFloat:
  372.                             CopyStrOver(Buffer,"fixedtofloat",&BuffIndex);
  373.                             goto ScanPlusOnePoint;
  374.                         case epOperationFixedToDouble:
  375.                             CopyStrOver(Buffer,"fixedtodouble",&BuffIndex);
  376.                             goto ScanPlusOnePoint;
  377.                         case epGetBooleanArraySize: /* <opcode> */
  378.                             CopyStrOver(Buffer,"arraysize.b",&BuffIndex);
  379.                             goto ScanPlusOnePoint;
  380.                         case epGetIntegerArraySize:
  381.                             CopyStrOver(Buffer,"arraysize.i",&BuffIndex);
  382.                             goto ScanPlusOnePoint;
  383.                         case epGetFloatArraySize:
  384.                             CopyStrOver(Buffer,"arraysize.s",&BuffIndex);
  385.                             goto ScanPlusOnePoint;
  386.                         case epGetDoubleArraySize:
  387.                             CopyStrOver(Buffer,"arraysize.d",&BuffIndex);
  388.                             goto ScanPlusOnePoint;
  389.                         case epGetFixedArraySize:
  390.                             CopyStrOver(Buffer,"arraysize.f",&BuffIndex);
  391.                             goto ScanPlusOnePoint;
  392.                         case epReturnFromSubroutine: /* <opcode> */
  393.                             CopyStrOver(Buffer,"return",&BuffIndex);
  394.                             goto ScanPlusOnePoint;
  395.                         case epLoadImmediateNILArray: /* <opcode> */
  396.                             CopyStrOver(Buffer,"loadnull",&BuffIndex);
  397.                             goto ScanPlusOnePoint;
  398.                         case epOperationBooleanXor:
  399.                             CopyStrOver(Buffer,"xor.b",&BuffIndex);
  400.                             goto ScanPlusOnePoint;
  401.                         case epOperationIntegerAnd:
  402.                             CopyStrOver(Buffer,"and.i",&BuffIndex);
  403.                             goto ScanPlusOnePoint;
  404.                         case epOperationFixedAnd:
  405.                             CopyStrOver(Buffer,"and.f",&BuffIndex);
  406.                             goto ScanPlusOnePoint;
  407.                         case epOperationIntegerOr:
  408.                             CopyStrOver(Buffer,"or.i",&BuffIndex);
  409.                             goto ScanPlusOnePoint;
  410.                         case epOperationFixedOr:
  411.                             CopyStrOver(Buffer,"or.f",&BuffIndex);
  412.                             goto ScanPlusOnePoint;
  413.                         case epOperationIntegerXor:
  414.                             CopyStrOver(Buffer,"xor.i",&BuffIndex);
  415.                             goto ScanPlusOnePoint;
  416.                         case epOperationFixedXor:
  417.                             CopyStrOver(Buffer,"xor.f",&BuffIndex);
  418.                             goto ScanPlusOnePoint;
  419.                         case epOperationIntegerImpreciseDivide:
  420.                             CopyStrOver(Buffer,"divimpr.i",&BuffIndex);
  421.                             goto ScanPlusOnePoint;
  422.                         case epOperationFloatShiftLeft:
  423.                             CopyStrOver(Buffer,"shl.s",&BuffIndex);
  424.                             goto ScanPlusOnePoint;
  425.                         case epOperationDoubleShiftLeft:
  426.                             CopyStrOver(Buffer,"shl.d",&BuffIndex);
  427.                             goto ScanPlusOnePoint;
  428.                         case epOperationFloatShiftRight:
  429.                             CopyStrOver(Buffer,"shr.s",&BuffIndex);
  430.                             goto ScanPlusOnePoint;
  431.                         case epOperationDoubleShiftRight:
  432.                             CopyStrOver(Buffer,"shr.d",&BuffIndex);
  433.                             goto ScanPlusOnePoint;
  434.                         case epOperationIntegerNot:
  435.                             CopyStrOver(Buffer,"not.i",&BuffIndex);
  436.                             goto ScanPlusOnePoint;
  437.                         case epOperationDoubleAsin:
  438.                             CopyStrOver(Buffer,"asin.d",&BuffIndex);
  439.                             goto ScanPlusOnePoint;
  440.                         case epOperationDoubleAcos:
  441.                             CopyStrOver(Buffer,"acos.d",&BuffIndex);
  442.                             goto ScanPlusOnePoint;
  443.                         case epOperationDoubleSqr:
  444.                             CopyStrOver(Buffer,"sqr.d",&BuffIndex);
  445.                             goto ScanPlusOnePoint;
  446.                         case epOperationTestIntegerNegative:
  447.                             CopyStrOver(Buffer,"isneg.i",&BuffIndex);
  448.                             goto ScanPlusOnePoint;
  449.                         case epOperationTestFloatNegative:
  450.                             CopyStrOver(Buffer,"isneg.s",&BuffIndex);
  451.                             goto ScanPlusOnePoint;
  452.                         case epOperationTestDoubleNegative:
  453.                             CopyStrOver(Buffer,"isneg.d",&BuffIndex);
  454.                             goto ScanPlusOnePoint;
  455.                         case epOperationTestFixedNegative:
  456.                             CopyStrOver(Buffer,"isneg.f",&BuffIndex);
  457.                             goto ScanPlusOnePoint;
  458.                         case epOperationGetSignInteger:
  459.                             CopyStrOver(Buffer,"sign.i",&BuffIndex);
  460.                             goto ScanPlusOnePoint;
  461.                         case epOperationGetSignFloat:
  462.                             CopyStrOver(Buffer,"sign.s",&BuffIndex);
  463.                             goto ScanPlusOnePoint;
  464.                         case epOperationGetSignDouble:
  465.                             CopyStrOver(Buffer,"sign.d",&BuffIndex);
  466.                             goto ScanPlusOnePoint;
  467.                         case epOperationGetSignFixed:
  468.                             CopyStrOver(Buffer,"sign.f",&BuffIndex);
  469.                             goto ScanPlusOnePoint;
  470.                         case epPrintBool:
  471.                             CopyStrOver(Buffer,"print.b",&BuffIndex);
  472.                             goto ScanPlusOnePoint;
  473.                         case epPrintDouble:
  474.                             CopyStrOver(Buffer,"print.d",&BuffIndex);
  475.                             goto ScanPlusOnePoint;
  476.  
  477.                         case epStackPop: /* <opcode> */
  478.                             CopyStrOver(Buffer,"pop",&BuffIndex);
  479.                             goto ScanPlusOnePoint;
  480.                         case epStackDeallocateUnder: /* <opcode> <numwords> */
  481.                             CopyStrOver(Buffer,"popmultipleunder ",&BuffIndex);
  482.                             goto AppendInteger;
  483.                         case epDuplicate: /* <opcode> */
  484.                             CopyStrOver(Buffer,"dup",&BuffIndex);
  485.                             goto ScanPlusOnePoint;
  486.                         case epStackPopMultiple: /* <opcode> <numwords> */
  487.                             CopyStrOver(Buffer,"popmultiple ",&BuffIndex);
  488.                             goto AppendInteger;
  489.                         case epStackAllocate: /* <opcode> */
  490.                             CopyStrOver(Buffer,"alloc",&BuffIndex);
  491.                             goto ScanPlusOnePoint;
  492.  
  493.                         case epNop: /* <opcode> */
  494.                             CopyStrOver(Buffer,"nop",&BuffIndex);
  495.                             goto ScanPlusOnePoint;
  496.  
  497.                         case epOperationBooleanToIntegerBuried: /* <opcode> <stackindex> */
  498.                             CopyStrOver(Buffer,"booltoint Stack[",&BuffIndex);
  499.                             goto AppendStack;
  500.                         case epOperationBooleanToFloatBuried: /* <opcode> <stackindex> */
  501.                             CopyStrOver(Buffer,"booltofloat Stack[",&BuffIndex);
  502.                             goto AppendStack;
  503.                         case epOperationBooleanToDoubleBuried: /* <opcode> <stackindex> */
  504.                             CopyStrOver(Buffer,"booltodouble Stack[",&BuffIndex);
  505.                             goto AppendStack;
  506.                         case epOperationBooleanToFixedBuried: /* <opcode> <stackindex> */
  507.                             CopyStrOver(Buffer,"booltofixed Stack[",&BuffIndex);
  508.                             goto AppendStack;
  509.                         case epOperationIntegerToBooleanBuried: /* <opcode> <stackindex> */
  510.                             CopyStrOver(Buffer,"inttobool Stack[",&BuffIndex);
  511.                             goto AppendStack;
  512.                         case epOperationIntegerToFloatBuried: /* <opcode> <stackindex> */
  513.                             CopyStrOver(Buffer,"inttofloat Stack[",&BuffIndex);
  514.                             goto AppendStack;
  515.                         case epOperationIntegerToDoubleBuried: /* <opcode> <stackindex> */
  516.                             CopyStrOver(Buffer,"inttodouble Stack[",&BuffIndex);
  517.                             goto AppendStack;
  518.                         case epOperationIntegerToFixedBuried: /* <opcode> <stackindex> */
  519.                             CopyStrOver(Buffer,"inttofixed Stack[",&BuffIndex);
  520.                             goto AppendStack;
  521.                         case epOperationFloatToBooleanBuried: /* <opcode> <stackindex> */
  522.                             CopyStrOver(Buffer,"floattobool Stack[",&BuffIndex);
  523.                             goto AppendStack;
  524.                         case epOperationFloatToIntegerBuried: /* <opcode> <stackindex> */
  525.                             CopyStrOver(Buffer,"floattoint Stack[",&BuffIndex);
  526.                             goto AppendStack;
  527.                         case epOperationFloatToDoubleBuried: /* <opcode> <stackindex> */
  528.                             CopyStrOver(Buffer,"floattodouble Stack[",&BuffIndex);
  529.                             goto AppendStack;
  530.                         case epOperationFloatToFixedBuried: /* <opcode> <stackindex> */
  531.                             CopyStrOver(Buffer,"floattofixed Stack[",&BuffIndex);
  532.                             goto AppendStack;
  533.                         case epOperationDoubleToBooleanBuried: /* <opcode> <stackindex> */
  534.                             CopyStrOver(Buffer,"doubletobool Stack[",&BuffIndex);
  535.                             goto AppendStack;
  536.                         case epOperationDoubleToIntegerBuried: /* <opcode> <stackindex> */
  537.                             CopyStrOver(Buffer,"doubletoint Stack[",&BuffIndex);
  538.                             goto AppendStack;
  539.                         case epOperationDoubleToFloatBuried: /* <opcode> <stackindex> */
  540.                             CopyStrOver(Buffer,"doubletofloat Stack[",&BuffIndex);
  541.                             goto AppendStack;
  542.                         case epOperationDoubleToFixedBuried: /* <opcode> <stackindex> */
  543.                             CopyStrOver(Buffer,"doubletofixed Stack[",&BuffIndex);
  544.                             goto AppendStack;
  545.                         case epOperationFixedToBooleanBuried: /* <opcode> <stackindex> */
  546.                             CopyStrOver(Buffer,"fixedtobool Stack[",&BuffIndex);
  547.                             goto AppendStack;
  548.                         case epOperationFixedToIntegerBuried: /* <opcode> <stackindex> */
  549.                             CopyStrOver(Buffer,"fixedtoint Stack[",&BuffIndex);
  550.                             goto AppendStack;
  551.                         case epOperationFixedToFloatBuried: /* <opcode> <stackindex> */
  552.                             CopyStrOver(Buffer,"fixedtofloat Stack[",&BuffIndex);
  553.                             goto AppendStack;
  554.                         case epOperationFixedToDoubleBuried: /* <opcode> <stackindex> */
  555.                             CopyStrOver(Buffer,"fixedtodouble Stack[",&BuffIndex);
  556.                             goto AppendStack;
  557.  
  558.                         case epBranchUnconditional: /* <opcode> <branchoffset> */
  559.                             CopyStrOver(Buffer,"bra ",&BuffIndex);
  560.                          AppendInteger:
  561.                             StringTemp = IntegerToString(OpcodeArray[Scan + 1].ImmediateInteger);
  562.                             if (StringTemp == NIL)
  563.                                 {
  564.                                     goto FailurePoint;
  565.                                 }
  566.                             CopyData(StringTemp,&(Buffer[BuffIndex]),PtrSize(StringTemp));
  567.                             BuffIndex += PtrSize(StringTemp);
  568.                             ReleasePtr(StringTemp);
  569.                             goto ScanPlusTwoPoint;
  570.                         case epBranchIfZero:
  571.                             CopyStrOver(Buffer,"brz ",&BuffIndex);
  572.                             goto AppendInteger;
  573.                         case epBranchIfNotZero:
  574.                             CopyStrOver(Buffer,"brnz ",&BuffIndex);
  575.                             goto AppendInteger;
  576.  
  577.                         case epResizeBooleanArray2: /* <opcode> */
  578.                             CopyStrOver(Buffer,"resize.b",&BuffIndex);
  579.                             goto ScanPlusOnePoint;
  580.                         case epResizeIntegerArray2:
  581.                             CopyStrOver(Buffer,"resize.i",&BuffIndex);
  582.                             goto ScanPlusOnePoint;
  583.                         case epResizeFloatArray2:
  584.                             CopyStrOver(Buffer,"resize.s",&BuffIndex);
  585.                             goto ScanPlusOnePoint;
  586.                         case epResizeDoubleArray2:
  587.                             CopyStrOver(Buffer,"resize.d",&BuffIndex);
  588.                             goto ScanPlusOnePoint;
  589.                         case epResizeFixedArray2:
  590.                             CopyStrOver(Buffer,"resize.f",&BuffIndex);
  591.                             goto ScanPlusOnePoint;
  592.  
  593.                         case epStoreIntegerOnStack: /* <opcode> <stackindex> */
  594.                             CopyStrOver(Buffer,"store.i Stack[",&BuffIndex);
  595.                          AppendStack:
  596.                             StringTemp = IntegerToString(OpcodeArray[Scan + 1].ImmediateInteger);
  597.                             if (StringTemp == NIL)
  598.                                 {
  599.                                     goto FailurePoint;
  600.                                 }
  601.                             CopyData(StringTemp,&(Buffer[BuffIndex]),PtrSize(StringTemp));
  602.                             BuffIndex += PtrSize(StringTemp);
  603.                             ReleasePtr(StringTemp);
  604.                             Buffer[BuffIndex++] = ']';
  605.                             goto ScanPlusTwoPoint;
  606.                         case epStoreFloatOnStack:
  607.                             CopyStrOver(Buffer,"store.s Stack[",&BuffIndex);
  608.                             goto AppendStack;
  609.                         case epStoreDoubleOnStack:
  610.                             CopyStrOver(Buffer,"store.d Stack[",&BuffIndex);
  611.                             goto AppendStack;
  612.                         case epStoreArrayOnStack:
  613.                             CopyStrOver(Buffer,"store.a Stack[",&BuffIndex);
  614.                             goto AppendStack;
  615.                         case epLoadIntegerFromStack:
  616.                             CopyStrOver(Buffer,"load.i Stack[",&BuffIndex);
  617.                             goto AppendStack;
  618.                         case epLoadFloatFromStack:
  619.                             CopyStrOver(Buffer,"load.s Stack[",&BuffIndex);
  620.                             goto AppendStack;
  621.                         case epLoadDoubleFromStack:
  622.                             CopyStrOver(Buffer,"load.d Stack[",&BuffIndex);
  623.                             goto AppendStack;
  624.                         case epLoadArrayFromStack:
  625.                             CopyStrOver(Buffer,"load.a Stack[",&BuffIndex);
  626.                             goto AppendStack;
  627.  
  628.                         case epMakeBooleanArray: /* <opcode> */
  629.                             CopyStrOver(Buffer,"newarray.b",&BuffIndex);
  630.                             goto ScanPlusOnePoint;
  631.                         case epMakeIntegerArray:
  632.                             CopyStrOver(Buffer,"newarray.i",&BuffIndex);
  633.                             goto ScanPlusOnePoint;
  634.                         case epMakeFloatArray:
  635.                             CopyStrOver(Buffer,"newarray.s",&BuffIndex);
  636.                             goto ScanPlusOnePoint;
  637.                         case epMakeDoubleArray:
  638.                             CopyStrOver(Buffer,"newarray.d",&BuffIndex);
  639.                             goto ScanPlusOnePoint;
  640.                         case epMakeFixedArray:
  641.                             CopyStrOver(Buffer,"newarray.f",&BuffIndex);
  642.                             goto ScanPlusOnePoint;
  643.  
  644.                         case epStoreBooleanIntoArray2: /* <opcode> */
  645.                             CopyStrOver(Buffer,"store.b Array[]",&BuffIndex);
  646.                             goto ScanPlusOnePoint;
  647.                         case epStoreIntegerIntoArray2:
  648.                             CopyStrOver(Buffer,"store.i Array[]",&BuffIndex);
  649.                             goto ScanPlusOnePoint;
  650.                         case epStoreFloatIntoArray2:
  651.                             CopyStrOver(Buffer,"store.s Array[]",&BuffIndex);
  652.                             goto ScanPlusOnePoint;
  653.                         case epStoreDoubleIntoArray2:
  654.                             CopyStrOver(Buffer,"store.d Array[]",&BuffIndex);
  655.                             goto ScanPlusOnePoint;
  656.                         case epStoreFixedIntoArray2:
  657.                             CopyStrOver(Buffer,"store.f Array[]",&BuffIndex);
  658.                             goto ScanPlusOnePoint;
  659.                         case epLoadBooleanFromArray2: /* <opcode> */
  660.                             CopyStrOver(Buffer,"load.b Array[]",&BuffIndex);
  661.                             goto ScanPlusOnePoint;
  662.                         case epLoadIntegerFromArray2:
  663.                             CopyStrOver(Buffer,"load.i Array[]",&BuffIndex);
  664.                             goto ScanPlusOnePoint;
  665.                         case epLoadFloatFromArray2:
  666.                             CopyStrOver(Buffer,"load.s Array[]",&BuffIndex);
  667.                             goto ScanPlusOnePoint;
  668.                         case epLoadDoubleFromArray2:
  669.                             CopyStrOver(Buffer,"load.d Array[]",&BuffIndex);
  670.                             goto ScanPlusOnePoint;
  671.                         case epLoadFixedFromArray2:
  672.                             CopyStrOver(Buffer,"load.f Array[]",&BuffIndex);
  673.                             goto ScanPlusOnePoint;
  674.  
  675.                         case epLoadImmediateInteger: /* <opcode> <integer>; also used for boolean & fixed */
  676.                             CopyStrOver(Buffer,"load.i #",&BuffIndex);
  677.                             goto AppendInteger;
  678.                         case epLoadImmediateFloat: /* <opcode> ^<float> */
  679.                             CopyStrOver(Buffer,"load.s #",&BuffIndex);
  680.                          AppendFloat:
  681.                             StringTemp = LongDoubleToString(*(OpcodeArray[Scan + 1]
  682.                                 .ImmediateFloat),8,1e-4,1e6);
  683.                             if (StringTemp == NIL)
  684.                                 {
  685.                                     goto FailurePoint;
  686.                                 }
  687.                             CopyData(StringTemp,&(Buffer[BuffIndex]),PtrSize(StringTemp));
  688.                             BuffIndex += PtrSize(StringTemp);
  689.                             ReleasePtr(StringTemp);
  690.                             goto ScanPlusTwoPoint;
  691.  
  692.                         case epLoadImmediateDouble: /* <opcode> ^<double> */
  693.                             CopyStrOver(Buffer,"load.d #",&BuffIndex);
  694.                          AppendDouble:
  695.                             StringTemp = LongDoubleToString(*(OpcodeArray[Scan + 1]
  696.                                 .ImmediateDouble),17,1e-4,1e6);
  697.                             if (StringTemp == NIL)
  698.                                 {
  699.                                     goto FailurePoint;
  700.                                 }
  701.                             CopyData(StringTemp,&(Buffer[BuffIndex]),PtrSize(StringTemp));
  702.                             BuffIndex += PtrSize(StringTemp);
  703.                             ReleasePtr(StringTemp);
  704.                             goto ScanPlusTwoPoint;
  705.  
  706.                         case epGetSampleLeftArray: /* <opcode> ^"<namestring>" */
  707.                             CopyStrOver(Buffer,"getsampleft.f ",&BuffIndex);
  708.                             goto AppendStringPoint;
  709.                         case epGetSampleRightArray: /* <opcode> ^"<namestring>" */
  710.                             CopyStrOver(Buffer,"getsampright.f ",&BuffIndex);
  711.                             goto AppendStringPoint;
  712.                         case epGetSampleMonoArray: /* <opcode> ^"<namestring>" */
  713.                             CopyStrOver(Buffer,"getsampmono.f ",&BuffIndex);
  714.                             goto AppendStringPoint;
  715.                         case epGetWaveTableArray: /* <opcode> ^"<namestring>" */
  716.                             CopyStrOver(Buffer,"getwaveframecount.i ",&BuffIndex);
  717.                             goto AppendStringPoint;
  718.                         case epGetWaveTableFrames: /* <opcode> ^"<namestring>" */
  719.                             CopyStrOver(Buffer,"getwavetablecount.i ",&BuffIndex);
  720.                             goto AppendStringPoint;
  721.                         case epGetWaveTableTables: /* <opcode> ^"<namestring>" */
  722.                             CopyStrOver(Buffer,"getwavetablearray.f ",&BuffIndex);
  723.                             goto AppendStringPoint;
  724.                         case epPrintString: /* <opcode> ^"<string>" */
  725.                             CopyStrOver(Buffer,"print ",&BuffIndex);
  726.                             goto AppendStringPoint;
  727.  
  728.                         default:
  729.                             EXECUTE(PRERR(ForceAbort,"DisassemblePcode:  unknown opcode"));
  730.                             break;
  731.                     }
  732.                 if (BuffIndex < DISBUFSIZE)
  733.                     {
  734.                         Buffer[BuffIndex] = CarriageReturn;
  735.                         BuffIndex += 1;
  736.                     }
  737.                  else
  738.                     {
  739.                         Buffer[BuffIndex - 1] = CarriageReturn;
  740.                     }
  741.                 ERROR(BuffIndex > DISBUFSIZE,PRERR(ForceAbort,"DisassemblePcode:  buffer overrun"));
  742.                 StringTemp = ResizePtr(Thang,PtrSize(Thang) + BuffIndex);
  743.                 if (StringTemp == NIL)
  744.                     {
  745.                         goto FailurePoint;
  746.                     }
  747.                 Thang = StringTemp;
  748.                 PRNGCHK(Thang,&(Thang[PtrSize(Thang) - BuffIndex]),BuffIndex);
  749.                 CopyData(Buffer,&(Thang[PtrSize(Thang) - BuffIndex]),BuffIndex);
  750.             }
  751.         return Thang;
  752.     }
  753.